package org.tuoren.official.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.tuoren.common.core.domain.R;
import org.tuoren.common.mybatis.core.page.PageQuery;
import org.tuoren.common.mybatis.core.page.TableDataInfo;
import org.tuoren.common.web.core.BaseController;
import org.tuoren.official.es.domain.TNewsCenterES;
import org.tuoren.official.service.ITNewsCenterESService;

/**
 * Es 搜索
 *
 * @author wp
 * @date 2024-11-29
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/es/news")
public class TNewsCenterESController extends BaseController {
    private final ITNewsCenterESService newsCenterESService;

    /**
     * 初始化ES新闻中心数据
     */
    @SaIgnore
    @GetMapping("/initANewsEs")
    public R<Void> initNewsEs() {
        return newsCenterESService.initNewsES();
    }

    /**
     * ES 获取新闻中心列表
     */
    @SaIgnore
    @GetMapping("/search")
    public TableDataInfo<TNewsCenterES> searchNewsES(Integer year,Integer month,String desc, PageQuery pageQuery){
        return newsCenterESService.searchNewsES(year,month,desc,pageQuery);
    }

}
